// 应用模块
export default {
  namespaced: true,

  state: {
    collapsed: false, // 菜单折叠状态
    selectedMenuKey: 'home' // 当前选中的菜单
  },

  mutations: {
    SET_COLLAPSED(state, collapsed) {
      state.collapsed = collapsed
    },

    SET_SELECTED_MENU_KEY(state, key) {
      state.selectedMenuKey = key
    }
  },

  actions: {
    toggleCollapsed({ commit, state }) {
      commit('SET_COLLAPSED', !state.collapsed)
    },

    setSelectedMenuKey({ commit }, key) {
      commit('SET_SELECTED_MENU_KEY', key)
    }
  },

  getters: {
    collapsed: state => state.collapsed,
    selectedMenuKey: state => state.selectedMenuKey
  }
}